#ifndef INPUTDATA_H
#define INPUTDATA_H

#include <string>
#include <cstdio>
#include <vector>
#include <set>
#include <map>

#include "utils.h"

struct Pos{
    int x, y;
    Pos(int x, int y): x(x), y(y) {}
    Pos() {}
    friend bool operator<(const Pos& a, const Pos& b) {
        if(a.x != b.x) {
            return a.x < b.x;
        }
        else {
            return a.y < b.y;
        }
    }
};

typedef std::set<Pos> Points;

class QString;

class InputData
{
public:
    InputData();
    void readData(int index);
    void readData(const QString& videoName);
    void writeData();
    int dataIndex;
    std::map<int64, Points> *pts = nullptr;
    std::set<int64> *frameId = nullptr;

protected:
    void initFilePath();
    void openFileRead();
    void openFileWrite();
    void closeFile();

    int frameNum;
    std::string timeLineFilePath, tipslineFilePath, tipsPointsFilePath, videoPath;
    std::string dataDirPath;
    FILE *timelineFp = nullptr, *tipslineFp = nullptr, *tipsPointsFp = nullptr;

};

#endif // INPUTDATA_H
